﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Xml.Linq;
using Common;

namespace PreguntaAlExperto
{
    /// <summary>
    /// Summary description for $codebehindclassname$
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class wlwmanifest : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            string rootUrl = String.Format("{0}://{1}:{2}/",
                context.Request.Url.Scheme, context.Request.Url.Host,
                context.Request.Url.Port);

             XNamespace ns = "http://schemas.microsoft.com/wlw/manifest/weblog";
             XDocument xmlDocument = new XDocument(new XElement(ns + "manifest",
                 new XElement(ns + "options",
                     new XElement(ns + "clientType", "Metaweblog"),
                     new XElement(ns + "supportsScripts", "No"),
                     new XElement(ns + "supportsEmbeds", "Yes"),
                     new XElement(ns + "supportsNewCategories", "No"),
                     new XElement(ns + "supportsTrackbacks", "Np"),
                     new XElement(ns + "supportsEmptyTitle", "No"),
                     new XElement(ns + "supportsPostAsDraft", "No"),
                     new XElement(ns + "supportsFileUpload", "Yes"),
                     new XElement(ns + "supportsCategories", "Yes"),
                     new XElement(ns + "supportsCategoriesInline", "No"),
                     new XElement(ns + "supportsKeywords", "No"),
                     new XElement(ns + "supportsMultipleCategories", "Yes"),
                     new XElement(ns + "supportsHierarchicalCategories", "No"),
                     new XElement(ns + "supportsNewCategories", "No"),
                     new XElement(ns + "supportsNewCategoriesInline", "No"),
                     new XElement(ns + "supportsCommentPolicy", "No"),
                     new XElement(ns + "supportsPingPolicy", "Yes"),
                     new XElement(ns + "supportsAuthor", "No"),
                     new XElement(ns + "supportsSlug", "No"),
                     new XElement(ns + "supportsPassword", "No"),
                     new XElement(ns + "supportsExcerpt", "No"),
                     new XElement(ns + "supportsTrackbacks", "No"),
                     new XElement(ns + "supportsPages", "No"),
                     new XElement(ns + "supportsPageParent", "No"),
                     new XElement(ns + "supportsPageOrder", "No")
                     ),
                 new XElement(ns + "weblog",
                     new XElement(ns + "serviceName", "Pregunta al Experto"),
                     new XElement(ns + "homepageLinkText", "Ir a Pregunta al Experto")
                     //new XElement(ns + "adminLinkText", ""),
                     //new XElement(ns + "adminUrl", new XCData("http://localhost:3071/Admin")),
                     //new XElement(ns + "postEditingUrl", new XCData("http://localhost:3071/EditPost.aspx?postId={post-id}"))
                     ),
                 new XElement(ns + "views",
                     new XElement(ns + "default", "Normal"),
                     new XElement(ns + "view",
                         new XAttribute("type", "WebLayout"),
                         new XAttribute("src",
                             rootUrl + "WebLayout.htm")),
                     new XElement(ns + "view",
                         new XAttribute("type", "WebPreview"),
                         new XAttribute("src",
                             rootUrl + "WebPreview.htm")))));
          
             context.Response.Write(xmlDocument.ToString());
         }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
